export let bugs = [];

export default class Bug {
    constructor(app, options) {
        this.app = app;
        this.options = Object.assign(
            {
                bgColor: '#bdc3c7',
            },
            options
        );

        this.el = this.element();
        bugs.push(this);
    }

    element() {
        let div = document.createElement('div');
        div.classList.add('snake');
        div.style.backgroundColor = this.options.bgColor;
        div.style.left = this.options.left + 'px';
        div.style.top = this.options.top + 'px';

        return div;
    }

    static get left() {
        return bugs[0].el.offsetLeft;
    }

    static get top() {
        return bugs[0].el.offsetTop;
    }

    static remove() {
        let bug = bugs.pop();
        bug.el.remove();
    }
}
